home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gcc / gcc260utilsdoc.lha / gnu / man / man1 / tr.1 < prev    next >
Encoding:
Text File  |  1994-07-26  |  11.0 KB  |  331 lines

  1.  
  2.  
  3.  
  4. TR(1L)            Misc. Reference Manual Pages             TR(1L)
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      tr - translate or delete characters
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ttttrrrr [-cst] [--complement] [--squeeze-repeats] [- - truncate -
  13.      set1] string1 string2
  14.      ttttrrrr {-s,--squeeze-repeats} [-c] [--complement] string1
  15.      ttttrrrr {-d,--delete} [-c] string1
  16.      ttttrrrr {-d,--delete} {-s,--squeeze-repeats} [-c] [-- complement]
  17.      string1 string2
  18.  
  19.      GNU ttttrrrr also accepts the --help and --version options.
  20.  
  21. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  22.      This manual page documents the GNU version of ttttrrrr.... ttttrrrr  copies
  23.      the standard input to the standard output, performing one of
  24.      the following operations:
  25.  
  26.           +o translate, and optionally squeeze repeated characters
  27.           in the result
  28.           +o squeeze repeated characters
  29.           +o delete characters
  30.           +o delete characters, then squeeze  repeated  characters
  31.           from the result.
  32.  
  33.      The _s_t_r_i_n_g_1 and (if given) _s_t_r_i_n_g_2 arguments define  ordered
  34.      sets  of  characters,  referred  to  below as set1 and set2.
  35.      These sets are the characters of the input that ttttrrrr  operates
  36.      on.   The   - -_c_o_m_p_l_e_m_e_n_t (-_c) option replaces set1 with its
  37.      complement (all of the characters that are not in set1).
  38.  
  39.   SSSSPPPPEEEECCCCIIIIFFFFYYYYIIIINNNNGGGG SSSSEEEETTTTSSSS OOOOFFFF CCCCHHHHAAAARRRRAAAACCCCTTTTEEEERRRRSSSS
  40.      The format of the _s_t_r_i_n_g_1 and  _s_t_r_i_n_g_2  arguments  resembles
  41.      the  format  of  regular  expressions; however, they are not
  42.      regular expressions, only lists of characters.  Most charac-
  43.      ters  simply  represent themselves in these strings, but the
  44.      strings can contain the shorthands listed  below,  for  con-
  45.      venience.   Some  of  them  can  be  used only in _s_t_r_i_n_g_1 or
  46.      _s_t_r_i_n_g_2, as noted below.
  47.  
  48.      Backslash escapes.  A backslash followed by a character  not
  49.      listed below causes an error message.
  50.  
  51.      \a   Control-G.
  52.  
  53.      \b   Control-H.
  54.  
  55.      \f   Control-L.
  56.  
  57.      \n   Control-J.
  58.  
  59.      \r   Control-M.
  60.  
  61.  
  62.  
  63. FSF              Last change: GNU Text Utilities                1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TR(1L)            Misc. Reference Manual Pages             TR(1L)
  71.  
  72.  
  73.  
  74.      \t   Control-I.
  75.  
  76.      \v   Control-K.
  77.  
  78.      \ooo The character with the value given by _o_o_o, which  is  1
  79.           to 3 octal digits.
  80.  
  81.      \\   A backslash.
  82.  
  83.      Ranges.  The notation `_m-_n' expands to all of the characters
  84.      from  _m  through  _n,  in  ascending order.  _m should collate
  85.      before _n; if it doesn't, an error results.  As  an  example,
  86.      `0-9' is the same as `0123456789'.  Although GNU ttttrrrr does not
  87.      support the System V syntax that  uses  square  brackets  to
  88.      enclose  ranges,  translations specified in that format will
  89.      still work as long as the brackets in string1 correspond  to
  90.      identical brackets in string2.
  91.  
  92.      Repeated  characters.   The  notation  `[_c*_n]'  in   _s_t_r_i_n_g_2
  93.      expands  to  _n  copies of character _c.  Thus, `[y*6]' is the
  94.      same as `yyyyyy'.  The notation `[_c*]' in _s_t_r_i_n_g_2 expands to
  95.      as  many  copies  of _c as are needed to make set2 as long as
  96.      set1.  If _n begins with a 0, it  is  interpreted  in  octal,
  97.      otherwise in decimal.
  98.  
  99.      Character classes.  The notation `[:_c_l_a_s_s-_n_a_m_e:]' expands to
  100.      all  of  the  characters  in  the  (predefined)  class named
  101.      _c_l_a_s_s-_n_a_m_e.  The characters expand in no  particular  order,
  102.      except  for the `upper' and `lower' classes, which expand in
  103.      ascending order.  When the --_d_e_l_e_t_e (-_d) and   - - _s_q_u_e_e_z_e -
  104.      _r_e_p_e_a_t_s (-_s) options are both given, any character class can
  105.      be used in _s_t_r_i_n_g_2.  Otherwise, only the  character  classes
  106.      `lower'  and  `upper' are accepted in _s_t_r_i_n_g_2, and then only
  107.      if the corresponding character class (`upper'  and  `lower',
  108.      respectively)  is specified in the same relative position in
  109.      _s_t_r_i_n_g_1.  Doing this specifies case conversion.   The  class
  110.      names  are  given  below;  an  error results when an invalid
  111.      class name is given.
  112.  
  113.      alnum
  114.           Letters and digits.
  115.  
  116.      alpha
  117.           Letters.
  118.  
  119.      blank
  120.           Horizontal whitespace.
  121.  
  122.      cntrl
  123.           Control characters.
  124.  
  125.      digit
  126.  
  127.  
  128.  
  129. FSF              Last change: GNU Text Utilities                2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. TR(1L)            Misc. Reference Manual Pages             TR(1L)
  137.  
  138.  
  139.  
  140.           Digits.
  141.  
  142.      graph
  143.           Printable characters, not including space.
  144.  
  145.      lower
  146.           Lowercase letters.
  147.  
  148.      print
  149.           Printable characters, including space.
  150.  
  151.      punct
  152.           Punctuation characters.
  153.  
  154.      space
  155.           Horizontal or vertical whitespace.
  156.  
  157.      upper
  158.           Uppercase letters.
  159.  
  160.      xdigit
  161.           Hexadecimal digits.
  162.  
  163.      Equivalence classes.  The syntax `[=_c=]' expands to  all  of
  164.      the  characters  that  are equivalent to _c, in no particular
  165.      order.  Equivalence classes are a recent invention  intended
  166.      to  support non-English alphabets.  But there seems to be no
  167.      standard way to define them  or  determine  their  contents.
  168.      Therefore,  they  are  not fully implemented in GNU ttttrrrr; each
  169.      character's equivalence class consists only of that  charac-
  170.      ter, which makes this a useless construction currently.
  171.  
  172.   TTTTRRRRAAAANNNNSSSSLLLLAAAATTTTIIIINNNNGGGG
  173.      ttttrrrr performs translation when _s_t_r_i_n_g_1 and  _s_t_r_i_n_g_2  are  both
  174.      given  and  the  - - delete  ( - _d) option is not given.  ttttrrrr
  175.      translates each character of its input that is  in  set1  to
  176.      the corresponding character in set2.  Characters not in set1
  177.      are passed through unchanged.  When a character appears more
  178.      than  once  in set1 and the corresponding characters in set2
  179.      are not all the same, only the final one is used.  For exam-
  180.      ple, these two commands are equivalent:
  181.           tr aaa xyz
  182.           tr a z
  183.  
  184.      A common use of ttttrrrr is to  convert  lowercase  characters  to
  185.      uppercase.   This  can be done in many ways.  Here are three
  186.      of them:
  187.           tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  188.           tr a-z A-Z
  189.           tr '[:lower:]' '[:upper:]'
  190.  
  191.  
  192.  
  193.  
  194.  
  195. FSF              Last change: GNU Text Utilities                3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. TR(1L)            Misc. Reference Manual Pages             TR(1L)
  203.  
  204.  
  205.  
  206.      When ttttrrrr is performing translation, set1 and set2 should nor-
  207.      mally  have  the same length.  If set1 is shorter than set2,
  208.      the extra characters at the end of set2 are ignored.
  209.  
  210.      On the other hand, making set1 longer than set2 is not port-
  211.      able;  POSIX.2  says  that the result is undefined.  In this
  212.      situation, the BSD ttttrrrr pads set2 to the  length  of  set1  by
  213.      repeating the last character of set2 as many times as neces-
  214.      sary.  The System V ttttrrrr truncates set1 to the length of set2.
  215.  
  216.      By default, GNU ttttrrrr handles this case like the BSD  ttttrrrr  does.
  217.      When  the  --truncate-set1 (-_t) option is given, GNU ttttrrrr han-
  218.      dles this case like the System V ttttrrrr instead.  This option is
  219.      ignored for operations other than translation.
  220.  
  221.      Acting like the System V ttttrrrr in this case  breaks  the  rela-
  222.      tively common BSD idiom:
  223.           tr -cs A-Za-z0-9 '\012'
  224.      because it converts only zero bytes (the  first  element  in
  225.      the  complement of set1), rather than all non-alphanumerics,
  226.      to newlines.
  227.  
  228.   SSSSQQQQUUUUEEEEEEEEZZZZIIIINNNNGGGG RRRREEEEPPPPEEEEAAAATTTTSSSS AAAANNNNDDDD DDDDEEEELLLLEEEETTTTIIIINNNNGGGG
  229.      When given just the --delete (-_d)  option,  ttttrrrr  removes  any
  230.      input characters that are in set1.
  231.  
  232.      When given just the --squeeze - repeats  ( - _s)  option,  ttttrrrr
  233.      replaces each input sequence of a repeated character that is
  234.      in set1 with a single occurrence of that character.
  235.  
  236.      When given both the --delete and  the  - - squeeze - repeats
  237.      options,  ttttrrrr  first  performs any deletions using set1, then
  238.      squeezes repeats from any remaining characters using set2.
  239.  
  240.      The --squeeze-repeats option may also be used when translat-
  241.      ing,  in  which  case  ttttrrrr  first  performs translation, then
  242.      squeezes repeats from any remaining characters using set2.
  243.  
  244.      Here are some examples to illustrate various combinations of
  245.      options:
  246.  
  247.      Remove all zero bytes:
  248.           tr -d '\000'
  249.  
  250.      Put all words on lines by  themselves.   This  converts  all
  251.      non-alphanumeric  characters to newlines, then squeezes each
  252.      string of repeated newlines into a single newline:
  253.           tr -cs '[a-zA-Z0-9]' '[\n*]'
  254.  
  255.      Convert each sequence of repeated newlines to a single  new-
  256.      line:
  257.           tr -s '\n'
  258.  
  259.  
  260.  
  261. FSF              Last change: GNU Text Utilities                4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. TR(1L)            Misc. Reference Manual Pages             TR(1L)
  269.  
  270.  
  271.  
  272.      GNU ttttrrrr also accepts the following options in any combination
  273.      with the others.
  274.  
  275.      --_h_e_l_p
  276.           Print a usage message and exit with a non-zero status.
  277.  
  278.      --_v_e_r_s_i_o_n
  279.           Print version information on standard output then exit.
  280.  
  281.   WWWWAAAARRRRNNNNIIIINNNNGGGG MMMMEEEESSSSSSSSAAAAGGGGEEEESSSS
  282.      Setting the environment variable POSIXLY_CORRECT  turns  off
  283.      several  warning  and  error messages, for strict compliance
  284.      with POSIX.2.  The messages normally occur in the  following
  285.      circumstances:
  286.  
  287.      1.  When the --_d_e_l_e_t_e option is given but --_s_q_u_e_e_z_e- _r_e_p_e_a_t_s
  288.      is  not,  and  _s_t_r_i_n_g_2  is given, GNU ttttrrrr by default prints a
  289.      usage message and exits, because _s_t_r_i_n_g_2 would not be  used.
  290.      The POSIX specification says that _s_t_r_i_n_g_2 must be ignored in
  291.      this case.  Silently ignoring arguments is a bad idea.
  292.  
  293.      2.  When an ambiguous octal escape is given.   For  example,
  294.      \400  is  actually  \40 followed by the digit 0, because the
  295.      value 400 octal does not fit into a single byte.
  296.  
  297.      Note that GNU ttttrrrr does not provide complete BSD or  System  V
  298.      compatibility.   For  example, there is no option to disable
  299.      interpretation of the POSIX constructs [:alpha:], [=c=], and
  300.      [c*10].   Also,  GNU ttttrrrr does not delete zero bytes automati-
  301.      cally, unlike traditional UNIX versions,  which  provide  no
  302.      way to preserve zero bytes.
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327. FSF              Last change: GNU Text Utilities                5
  328.  
  329.  
  330.  
  331.